﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace LAN_Party_Manager
{
    public partial class frmAdd : Form
    {
        public frmAdd()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (txtName.Text.Length == 0)
                MessageBox.Show("Please enter a name.");

            Player newPlayer = new Player(txtName.Text, chkActive.Checked);
            Player.players.Add(newPlayer);
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void frmAdd_Load(object sender, EventArgs e)
        {
            chkActive.Checked = true;
        }

        private void txtName_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                if (txtName.Text.Length == 0)
                    MessageBox.Show("Please enter a name.");

                Player newPlayer = new Player(txtName.Text, chkActive.Checked);
                Player.players.Add(newPlayer);
                e.SuppressKeyPress = true;
                this.DialogResult = DialogResult.OK;
                this.Close();

            }
        }
    }
}
